package com.mangguo.tingjian.account.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mangguo.tingjian.account.dto.DeptDto;
import com.mangguo.tingjian.account.mapper.DeptMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class DeptService {

    @Resource
    private DeptMapper deptMapper;

    public List<DeptDto> findAllDept(){
        return deptMapper.selectList(new QueryWrapper<>()).stream()
                .map(dept -> DeptDto.builder().id(dept.getId()).name(dept.getName()).build()).collect(Collectors.toList());
    }

}
